//转盘抽奖

	var time_message="";
	var waite_ajax = "";
	var num = 0;
	var canClick=true;
	var zhuan = document.querySelector(".p13_zhuan");
	var car = document.querySelector(".p13_car");
	$(".p13_hand").on("click",function(){
		//不允许客户反复点击
		var prize="";
		if(canClick){
			canClick=false;
			//等待ajax请求的数据返回,并模拟转动
			waite_ajax=setInterval(function(){
				num++;
				car.style.webkitTransform = "rotateZ("+20+num*7.2+"deg)";
			},10)
			$.ajax({
				type:"get",
				url:"rotate.php",
				async:true,
				success:function(data){
					clearInterval(waite_ajax);
					num=0;
					var deg=data;
					$(".p13_car").rotate({
						duration:8000,
						//等待获取ajax是转动的度数
						angle:20+(num*7.2)%360,
						animateTo:1800+parseInt(deg),
						easing:$.easing.easrOutExpo
					})
					var p14_win=document.querySelector(".p14_win>img");
					
					time_message=setTimeout(function(){
						if(deg==20){
							p14_win.src="img/prize1.png";
							$(".p14>").css("display","block");						
//							alert("恭喜获得海洋温泉门票");
							prize="恭喜获得海洋温泉门票";
						}else if(deg==65){
							$(".p14").css("display","block");
							p14_win.src="img/prize2.png";
//							alert("恭喜获得神秘欢乐岛门票");
							prize="恭喜获得神秘欢乐岛门票";
						}else if(deg==110){
							p14_win.src="img/prize3.png";
							$(".p14").css("display","block");
//							alert("恭喜获得梦幻剧场门票");
							prize="恭喜获得神秘欢乐岛门票";
						}else if(deg==155){
							p14_win.src="img/prize4.png";
							$(".p14").css("display","block");
//							alert("你获得了一份神秘奖品");
							prize="你获得了一份神秘奖品";
						}else if(deg==200){
							p14_win.src="img/prize5.png";
							$(".p14").css("display","block");
							prize="恭喜获得海泉湾吉祥公仔";
//							alert("恭喜获得海泉湾吉祥公仔");
						}else if(deg==245){
							p14_win.src="img/prize6.png";
							$(".p14").css("display","block");
							prize="恭喜获得明星海报";
//							alert("恭喜获得明星海报");
						}else if(deg==290){
							p14_win.src="img/prize7.png";
							$(".p14").css("display","block");
							prize="运气爆棚,赢得海景房一套";
//							alert("运气爆棚,赢得海景房一套");
						}
						canClick = true;
					},8000)	
				}
			});
		}
	})

//其他点击事件
	//碰到障碍物
	$(".p5_go1").on("click",function(){
		$(".p5b_all").css("display","none");
		$(".p1").css("display","block");
	});
	//排行榜
	$(".p5_paihang").on("click",function(){
		$(".p5b_all").css("display","none");
		$(".p7_all").css("display","block");
	});
	//过关,邀请导师
	$(".go").on("click",function(){
		$(".p5a_2").css("display","block");
		alert(1);
	});
	//分享朋友圈
	$(".arrow").on("click",function(){
		$(".p5_a,.p5a_2").css("display","none");
		$(".p8_all").css("display","block");
	});
	//好友选择晋级
	$(".bucuo").on("click",function(){
		$(".p8_all").css("display","none");
		$(".p11_all").css("display","block");
	});
	//点击抽奖
	$(".p11_go").on("click",function(){
		$(".p11_all").css("display","none");
		$(".p13").css("display","block");
	})
	//好友选择太差
	$(".taicha").on("click",function(){
		$(".p8_all").css("display","none");
		$(".p10").css("display","block");
	});
	//再玩一次go
	$(".p10_repeat").on("click",function(){
		$(".p10").css("display","none");
		$(".p1").css("display","block");
	})
	//排行榜
	$(".paiHangBang").on("click",function(){
		$(".p5_a").css("display","none");
		$(".p7_all").css("display","block");
	});
	//排行榜消失
	$(".p7_paiming").on("click",function(){
		$(".p5_a").css("display","block");
		$(".p7_all").css("display","none");
	})
	
	//点击填写信息
	$(".p14_msg").on("click",function(){
		$(".p14_msg,.p13").css("display","none");
		$(".p15_all").css("display","block");
	});
	//提交
	$(".p15_go").on("click",function(){
		$(".p15_all").css("display","none");
		var p16_text1=document.querySelector(".p16_text1");
		var p16_all=document.querySelector(".p16_all");
		var p16=document.createElement("div");
		p16.className="p16";
		p16_all.insertBefore(p16,p16_text1);
		$(".p16_all").css("display","block");
			var name=document.querySelector(".name").value;
			var phone=document.querySelector(".phone").value;
			var pro=document.querySelector(".pro").value;
			var city=document.querySelector(".city").value;
			var street=document.querySelector(".street").value;
		$.ajax({
					type:"get",
					url:"handle_hqw.php",
					async:true,
					data:{
						name:name,
						tel:phone,
						adress:pro+city+street,
						prize:prize
					},
					dataType:"json",
					success:function(json){
						alert(json);
					}
				});	
	});

//获取登记信息传后台数据库
function messages(){
	var name=document.querySelector(".name");
	var phone=document.querySelector(".phone");
	var pro=document.querySelector(".pro");	
	var city=document.querySelector(".city");
	var street=document.querySelector(".street");
	var xia1=document.querySelector(".xia1");
	var xia2=document.querySelector(".xia2");
	xia1.onclick=function(){
		pro.value = "辽宁";
	};
	xia2.onclick=function(){
		city.value="沙河口区";
		street.value="软件园蓝鸥科技有限公司";
	}		
}
messages();
